package planit.view;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import planit.controller.ControllerFactory;
import planit.controller.ControllerFactory.ControllerType;


/**
 * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
 * Builder, which is free for non-commercial use. If Jigloo is being used
 * commercially (ie, by a corporation, company or business for any purpose
 * whatever) then you should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details. Use of Jigloo implies
 * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
 * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
 * ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
@SuppressWarnings("serial")
public class GroupDialog extends javax.swing.JDialog{
	private JPanel jPanel1;
	private JLabel descriptionLabel;
	private JButton jButton1;
	private AbstractAction cancelAction;
	private JButton jButton2;
	private JTextArea descriptionTextArea;
	private JTextField nameTextField;
	private JLabel nameLabel;

	public GroupDialog() {
		super();
		initGUI();
	}

	private void initGUI() {
		try {
			{
				this.setPreferredSize(new java.awt.Dimension(314, 300));
			}
			{
				jPanel1 = new JPanel();
				getContentPane().add(jPanel1, BorderLayout.CENTER);
				jPanel1.setLayout(null);
				{
					nameLabel = new JLabel();
					jPanel1.add(nameLabel);
					nameLabel.setText("Name");
					nameLabel.setBounds(12, 12, 72, 16);
				}
				{
					descriptionLabel = new JLabel();
					jPanel1.add(descriptionLabel);
					descriptionLabel.setText("Description");
					descriptionLabel.setBounds(12, 44, 72, 16);
				}
				{
					nameTextField = new JTextField();
					jPanel1.add(nameTextField);
					nameTextField.setBounds(84, 9, 201, 29);
				}
				{
					descriptionTextArea = new JTextArea();
					jPanel1.add(descriptionTextArea);
					descriptionTextArea.setBounds(84, 44, 201, 181);
				}
				{
					jButton1 = new JButton();
					jPanel1.add(jButton1);
					jButton1.setText("Cancel");
					jButton1.setBounds(211, 231, 75, 23);
					jButton1.setAction(getCancelAction());
				}
				{
					jButton2 = new JButton();
					jPanel1.add(jButton2);
					jButton2.setAction(ControllerFactory
							.getController(ControllerType.CREATE_GROUP));
					jButton2.getAction().putValue("GroupDialog", this);
					jButton2.setText("Ok");
					jButton2.setBounds(137, 231, 68, 23);
				}
			}
			pack();
			this.setSize(314, 300);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public String getGroupName() {
		return nameTextField.getText();
	}

	public String getGroupDescription() {
		return descriptionTextArea.getText();
	}

	private AbstractAction getCancelAction() {
		if(cancelAction == null) {
			cancelAction = new AbstractAction("Cancel", null) {
				public void actionPerformed(ActionEvent evt) {
					dispose();
				}
			};
		}
		return cancelAction;
	}
}
